/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package EJB.Entity;

import Entity.Reserva;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.sql.Timestamp;
import java.util.List;
import javax.persistence.Query;

/**
 *
 * @author mquezada
 */
@Stateless
public class ReservaFacade extends AbstractFacade<Reserva> implements ReservaFacadeLocal {
    @PersistenceContext(unitName = "Webpizza-ejbPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public ReservaFacade() {
        super(Reserva.class);
    }

    @SuppressWarnings("unchecked")
	public List<Reserva> findByDate(Timestamp date){
        Query q = em.createNamedQuery("SELECT object(r) FROM Reservas AS r"+
                " WHERE r.fecha_objetivo = :date");
        q.setParameter("date",date);
        List<Reserva> aux = (List<Reserva>) q.getResultList();
        return aux;
    }

}
